/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ibmmodel3;

import java.util.Map;

/**
 *
 * @author mwh
 */
public class TranslationTableJDO implements TranslationTable {


    public double get(Integer source, Integer target) {
        throw new UnsupportedOperationException("Not supported yet.");
    }


    public Map<Integer, Double> get(Integer source) {
        throw new UnsupportedOperationException("Not supported yet.");
    }


    public double getLog10(int source, int target) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

//    PersistenceManager pm;
//
//
//    public TranslationTableJDO(TranslationTableMem ttMem, String dbName) throws FileNotFoundException, IOException {
//        Properties p = new Properties();
//        p.load(new FileInputStream("/home/mwh/DGS/IBMModel3/src/jpox.properties"));
//
//        p.setProperty("javax.jdo.option.ConnectionURL", "db4o:file:/home/mwh/DGS/databases/" + dbName);
//        PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(p);
//        pm = pmf.getPersistenceManager();
//        Transaction tx = pm.currentTransaction();
//        tx.setOptimistic(true);
//
//        tx.begin();
//
//        int n = 0;
//        for (Iterator<Integer> keyIt = ttMem.keyIterator(); keyIt.hasNext();) {
//            n++;
//            Integer key = keyIt.next();
//            Map<Integer, Double> translation = ttMem.get(key);
//
//            JDOTrans jt = new JDOTrans(key, translation);
//            pm.makePersistent(jt);
//            if (n == 100) {
//                tx.commit();
//                tx = pm.currentTransaction();
//                tx.setOptimistic(true);
//                tx.begin();
//                n = 0;
//            }
//        }
//        tx.commit();
//
//    }
//
//
//    
//    
//
//
//    public TranslationTableJDO(String dbName) throws FileNotFoundException, IOException {
//
//        Properties p = new Properties();
//        p.load(new FileInputStream("/home/mwh/DGS/IBMModel3/src/jpox.properties"));
//
//        p.setProperty("javax.jdo.option.ConnectionURL", "db4o:file:/home/mwh/DGS/databases/" + dbName);
//        PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(p);
//        pm = pmf.getPersistenceManager();
//
//    }
//
//
//    public Map<Integer, Double> get(Integer source) {
//        Transaction tx = pm.currentTransaction();
//        tx.begin();
//        JDOTrans jt = pm.getObjectById(JDOTrans.class, source);
//        return jt.getTranslations();
//    }
//
//
//    public double get(Integer source, Integer target) {
//        Map<Integer, Double> translations = get(source);
//        if (translations.containsKey(target)) {
//            return translations.get(target);
//        } else {
//            return translations.get(-1024);
//        }
//
//
//    }
//
//
//    @Override
//    protected void finalize() throws Throwable {
//        pm.close();
//    }
//
//
//    public double getLog10(int source, int target) {
//        return Math.log10(get(source, target));
//    }
}
